package com.rui.patterns.iterator;

/**
 * @author : [锐神NO.3]
 * @version : [v1.0]
 * @className : Client
 * @createTime : [2022/2/24 16:45]
 * @description : [描述该类的功能]
 */

public class Client {
    public static void main(String[] args) {
        //创建聚合对象
        StudentAggregateImpl aggregate = new StudentAggregateImpl();

        //添加元素
        aggregate.add(new Student("张三", "001"));
        aggregate.add(new Student("李四", "002"));
        aggregate.add(new Student("王五", "003"));
        aggregate.add(new Student("赵六", "004"));

        //遍历聚合对象
        StudentIterator iterator = aggregate.getStudentIterator();
        while (iterator.hasNext()) {
            Student student = iterator.next();
            System.out.println(student);
        }
    }
}
